<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="/resources/template/template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml"
                xmlns:p="http://primefaces.org/ui">


    <ui:define name="content">

        <h:panelGroup >
            <h:form  >
                <p:growl />
                <p:focus id="selectFocus" context="gpSelect" />
                <p:focus id="detailFocus" context="gpDetail" />



                <p:panel header="Manage Discount Scheme" >
                    <h:panelGrid id ="gpVeda" columns="2" >

                        <h:panelGrid id="gpSelect" columns="1"  >
                            <p:panel >
                                <h:outputText  value="MemberShip Scheme" />
                                <h:selectOneListbox  value="#{paymentSchemeController.membershipScheme}" size="1" >
                                    <f:selectItem itemLabel="Select membership Scheme"/>
                                    <f:selectItems value="#{membershipSchemeController.items}"/>
                                    <f:ajax event="change" render="@all" execute="@this" listener="#{paymentSchemeController.createPaymentSchemesMembership()}" />                                        
                                </h:selectOneListbox>
                                <h:panelGrid id="gpSelectText" >
                                    <h:selectOneListbox  id="lstSelect"   size="10" value="#{paymentSchemeController.current}" style="min-width: 223px">
                                        <f:selectItems  value="#{paymentSchemeController.itemsMemberShip}" var="myItem" itemValue="#{myItem}" itemLabel="#{myItem.name}" ></f:selectItems>
                                        <f:ajax render="gpDetail" execute="lstSelect" >
                                        </f:ajax>
                                    </h:selectOneListbox>
                                </h:panelGrid>
                                <h:panelGrid id="gpSelectButtons" columns="3"  >

                                    <p:commandButton ajax="false" id="btnAdd" value="Add" 
                                                    action="#{paymentSchemeController.prepareAdd()}" 
                                                     styleClass="buttons" />                                       
                                    

                                    <p:commandButton ajax="false" id="btnDelete" onclick="if (!confirm('Are you sure you want to delete this record?'))
                                                return false;" action="#{paymentSchemeController.delete()}"  value="Delete"  >
                                    </p:commandButton>

                                    <p:commandButton ajax="false" value="Fill"
                                                    action="#{paymentSchemeController.createPaymentSchemesMembership()}"/>

                                </h:panelGrid>
                            </p:panel>
                        </h:panelGrid  >

                        <p:panel>
                            <h:panelGrid id="gpDetail" columns="1">
                                <h:panelGrid id="gpDetailText" columns="2">
                                    <h:outputText id="lblName" value="Name" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtName" value="#{paymentSchemeController.current.name}"  ></h:inputText>
                                    <h:outputText id="lblPay" value="Payment Method" ></h:outputText>
                                    <h:selectOneListbox  id="cmbPay" value="#{paymentSchemeController.current.paymentMethod}" size="1" >
                                        <f:selectItem itemLabel="Select Payment Method"/>
                                        <f:selectItems value="#{paymentSchemeController.paymentMethods}"/>
                                    </h:selectOneListbox>

                                    <h:outputText id="lblOrder" value="Order No" />
                                    <h:inputText autocomplete="off" id="txtOrder" value="#{paymentSchemeController.current.orderNo}"  />

                                    <h:outputText id="lblClient" value="Client Type" ></h:outputText>
                                    <h:selectOneListbox  id="cmbClient" value="#{paymentSchemeController.current.cliantType}" size="1" >
                                        <f:selectItem itemLabel="Please select client type"/>
                                        <f:selectItem itemLabel="Outpatient" itemValue="Outpatient"/>
                                        <f:selectItem itemLabel="Inward" itemValue="Inward"/>
                                        <f:selectItem itemLabel="Institution" itemValue="Institution"/>
                                        <f:selectItem itemLabel="CollectingCentre" itemValue="CollectingCentre"/>
                                        <f:selectItem itemLabel="Staff" itemValue="Staff"/>
                                    </h:selectOneListbox>
                                    
                                    <h:outputText id="lblLab" value="Discount Percent for OPD" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtLab" value="#{paymentSchemeController.current.discountPercent}"  ></h:inputText>    
                                    <h:outputText id="lblPharmacy" value="Discount Percent for Pharmacy" ></h:outputText>
                                    <h:inputText autocomplete="off" id="txtPharmacy" value="#{paymentSchemeController.current.discountPercentForPharmacy}"  ></h:inputText>    


                                    <h:outputLabel rendered="#{paymentSchemeController.current!=null}"  value="Valid for Payments" />
                                    <p:selectBooleanCheckbox rendered="#{paymentSchemeController.current!=null}" value="#{paymentSchemeController.current.validForPharmacy}" ></p:selectBooleanCheckbox>
                                    <h:outputLabel rendered="#{paymentSchemeController.current!=null}"  value="Valid for Billing" />
                                    <p:selectBooleanCheckbox rendered="#{paymentSchemeController.current!=null}" value="#{paymentSchemeController.current.validForBilledBills}" ></p:selectBooleanCheckbox>
                                    <h:outputLabel rendered="#{paymentSchemeController.current!=null}"  value="Valid for Cancellings and Refunds" />
                                    <p:selectBooleanCheckbox rendered="#{paymentSchemeController.current!=null}" value="#{paymentSchemeController.current.validForCrBills}" ></p:selectBooleanCheckbox>

                                </h:panelGrid>
                                <h:panelGrid id="gpDetailButtons" columns="2">

                                    <h:commandButton id="btnSave" value="Save" action="#{paymentSchemeController.saveSelected()}" styleClass="buttons">                                        
                                    </h:commandButton>
                                    <p:defaultCommand target="btnSave"/>
                                </h:panelGrid>
                            </h:panelGrid>
                        </p:panel>
                    </h:panelGrid>
                </p:panel>
            </h:form>

        </h:panelGroup>

    </ui:define>

</ui:composition>
